#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>

int main()
{
    printf("process is running, only me! pid: %d\n", getpid());
    sleep(2);
    pid_t id = fork();
    if(id == -1)
    {
        return 1;
    }
    else if(id == 0)
    {
        while(1)
        {
            printf("id: %d, I am child process, pid: %d, ppid: %d\n", id ,getpid(), getppid());
            sleep(1);
        }
    }
    else
    {
        while(1)
        {
            printf("id: %d, I am parent process, pid: %d, ppid: %d\n", id ,getpid(), getppid());
            sleep(2);
        }
    }

    //pid_t pid = getpid();
    //while(1)
    //{
    //    printf("working, pid: %d\n", pid);
    //    sleep(1);
    //}

    return 0;
}
